import { Component, OnInit, OnDestroy } from '@angular/core';

import { Util } from '../../utils/util';

import { ProductDetailService } from './product.detail.page.service';

@Component({
  selector: 'app-brand-detail',
  templateUrl: './product.detail.page.html',
  providers: [ProductDetailService]
})
export class ProductDetailPage implements OnInit {

  productInfo: any;
  instest: boolean = false;

  constructor(private service: ProductDetailService, private util: Util) { }

  ngOnInit() {

    this.productInfo = this.util.sessionStore().get('productDetail');

    console.log(this.productInfo);

    this.getProductInfo();
    this.getProductDoubleInfo();
  }

  ngOnDestroy() {
    if (this.OffEvent) {
      this.OffEvent.unsubscribe();

    }

    if(this.OffDoubleEvent){
      this.OffDoubleEvent.unsubscribe();
    }
  }



  OffEvent: any;
  getProductInfo() {

    let json = {
      numberId: this.productInfo.numberId
    };

    var res = {"code":0,"msg":"成功","data":{"t":{"date":"2017-12-03 00:00:00","numberId":"37159234393","title":"【正品联保】Beats URBEATS 2.0重低音降噪入耳式耳机魔音B耳塞式","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i2/1974623778/TB1HecuapTM8KJjSZFlXXaO8FXa_!!0-item_pic.jpg","loc":"浙江杭州","propertyValue":"是否线控:是,品牌:Beats,耳机插头类型:直插型,套餐类型:官方标配,频响范围:20-20000Hz,耳机售后服务:全国联保,型号:URBEATS,耳机输出音源:随身视听,缆线长度:1.2M,阻抗:32Ω,耳机类型:有线,耳机类别:HIFI耳机,生产企业:美国苹果公司,适用音乐类型:摇滚金属重低音类型,插头直径:3.5mm,有无麦克风:带麦,兼容平台:ANDROID iOS,佩戴方式:入耳式,颜色分类:哑光黑 土豪银 玫瑰金色 土豪金 天空灰 紫色 深灰,保修期:12个月,灵敏度:108dB/mW","brandName":"beats","price":498.0,"monthPrice":498.0,"quantity":0,"monthSellAmount":2680,"monthSellMoney":1334640.0,"sellAmount":31,"sellMoney":15438.0,"category":"1205","catName":"数码/手机/家电--影音电器--耳机/耳麦","uid":"1974623778","shopName":"beats微先专卖店","shopType":"商城","publishTime":null},"interest":true}};

    setTimeout(() => {

      this.productInfo = res.data.t;

      this.instest = res.data.interest;

    }, 100);

  }

  // 11.11预售
  productDoble:any = {
    sellAmount: 0,
    dingJin: 0,
    sellMoney: 0
  };
  OffDoubleEvent: any;
  getProductDoubleInfo() {

    let json = {
      numberId: this.productInfo.numberId
    };

    this.productDoble = {
      sellAmount: 0,
      dingJin: 0,
      sellMoney: 0
    };

    var res = {"code":0,"msg":"成功","data":null};
    setTimeout(() => {

      if(res.data){
        this.productDoble = res.data;
      }



    }, 100);

  }

}
